//author: create by SunJH
//时间: 2021/11/22 0022
//邮箱: 965989158@qq.com
//描述: 日志拦截器
import 'package:dio/dio.dart';

import '../http_config.dart';

class MyLogInterceptor extends LogInterceptor {

  void Function(Object object) logPrint;

  MyLogInterceptor(bool isShow,{
    this.logPrint = printInfo,
  }) : super(request: isShow,
      requestHeader: isShow,
      requestBody: isShow,
      responseHeader: isShow,
      responseBody: isShow,
      error: isShow,
      logPrint: logPrint);


  static void printInfo(Object value){
    var params = value as String;
    var index = 700;//控制台输出有限制，超出不会显示，这里分批显示，一次显示700个字符
    while (params.isNotEmpty) {
      var end = params.length>index?index:params.length;
      var substring2 = params.substring(0, end);
      params = params.replaceRange(0, end, '');
      print(substring2);
    }
  }
}
